package com.faryangsh.enumpack.mutilChannel;

import static com.faryangsh.enumpack.mutilChannel.GameOutcome.*;

/**
 * 用枚举实现多路分发
 *
 * Created by 杨志远 on 2017/8/30
 * email faryangsh@163.com.
 */
public enum  MutilChnanel {
    ROCK(DRAW,LOSE,WIN),
    PAPER(WIN,DRAW,LOSE),
    SCISSORS(LOSE,WIN,DRAW);
    private GameOutcome vRock,vPaper,vScissors;

    private MutilChnanel(GameOutcome vRock,GameOutcome vPaper,GameOutcome vScissors ){
        this.vRock=vRock;
        this.vPaper=vPaper;
        this.vScissors=vScissors;
    }

    public GameOutcome compete(MutilChnanel mutilChnanel){
        switch (mutilChnanel){
            case PAPER:
                return this.vPaper;
            case ROCK:
                return this.vRock;
            case SCISSORS:
                return this.vScissors;
            default:
                return INVALID;
        }
    }

    public static void main(String[] args) {
        System.out.print(ROCK.compete(PAPER).getResult());
    }
}
